"""
页面装修
"""

from fastapi import APIRouter, Depends, Query

from forward.api.admin.schemas.decorate import (
    DecoratePageSaveInSchema,
    DecorateDataArticleInSchema,
    DecorateTabbarSaveInSchema,
)
from forward.api.admin.service.decorate.data_article import DecorateArticleService
from forward.api.admin.service.decorate.page import DecoratePageService
from forward.api.admin.service.decorate.tabbar import DecorateTabbarService
from forward.http_base import unified_resp

router = APIRouter(prefix="/decorate")


@router.post("/pages/save")
@unified_resp
async def pages_save(
    save_in: DecoratePageSaveInSchema,
    decorate_page_service: DecoratePageService = Depends(DecoratePageService.instance),
):
    """
     页面装修保存
    :return:
    """
    return await decorate_page_service.save(save_in)


@router.get("/pages/detail")
@unified_resp
async def pages_detail(
    id: int,
    decorate_page_service: DecoratePageService = Depends(DecoratePageService.instance),
):
    """
    页面装修详情
    :return:
    """
    return await decorate_page_service.detail(id)


@router.get("/tabbar/detail")
@unified_resp
async def tabbar_detail(
    tabbar_service: DecorateTabbarService = Depends(DecorateTabbarService.instance),
):
    """
    底部导航详情
    :return:
    """
    return await tabbar_service.detail()


@router.post("/tabbar/save")
@unified_resp
async def tabbar_save(
    save_in: DecorateTabbarSaveInSchema,
    tabbar_service: DecorateTabbarService = Depends(DecorateTabbarService.instance),
):
    """
    底部导航保存
    :return:
    """
    return await tabbar_service.save(save_in)


@router.get("/data/article")
@unified_resp
async def data_article(
    article_in: DecorateDataArticleInSchema = Depends(),
    decorate_article_service: DecorateArticleService = Depends(
        DecorateArticleService.instance
    ),
):
    """
    获取文章数据
    :return:
    """
    return await decorate_article_service.data_article(article_in=article_in)
